# Maintainer: Ray Donnelly <mingw.android@gmail.com>
# Maintainer: Martell Malone <martellmalone@gmail.com>

_realname="crosstool-ng"
pkgname="$_realname"-git
replaces=("$_realname")
pkgver=r4296.c609be17
pkgrel=1
pkgdesc="A cross-platform open-source toolchain system (git)"
arch=('i686' 'x86_64')
url="http://www.crosstool-ng.org/"
license=("MIT")
makedepends=("autoconf" "automake-wrapper" "binutils" "bison"
             "flex" "gettext-devel" "git" "gcc" "gperf"
             "patch" "libtool" "make" "ncurses-devel"
             "tar" "texinfo" "wget" "xz")
depends=("ncurses" "libintl")
options=('staticlibs' 'strip')
source=('crosstool-ng::git+https://github.com/crosstool-ng/crosstool-ng.git#branch=master'
         0001-stat-check.patch)
sha256sums=('SKIP'
            '53a283a29972490d1ddc369aa68ef1837240a195dbcfefa6a0a24b2f848c87d3')
pkgver() {
  cd "${srcdir}/${_realname}"
  echo "r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
}

prepare() {
  cd "${srcdir}/${_realname}"
  patch -p1 -i patch -p1 -i "${srcdir}/0001-stat-check.patch"
  ./bootstrap
  autoreconf -fiv
}

build() {
  cd "${srcdir}/${_realname}"
  ./configure \
    --build=${CHOST} \
    --prefix=/usr

  make
}

package() {
  cd "${srcdir}/${_realname}"
  make DESTDIR=${pkgdir} install
}
